//设置验证规则
let form = layui.form;
form.verify({
    len: [/^\S{6,12}$/, '长度必须6~12位且不能出现空格'],

    pwd2: function (b) {
        if (b === $('#oldpwd').val()) {
            return '新密码不能和原密码一致';
        }
    },
    pwd3: function (f) {
        if (f !== $('#newpwd').val()) {
            return '两次新密码不一致';
        }
    },

});
//获取表单的值

//提交数据
$('#restform').on('submit', function (e) {
    e.preventDefault();
    let rest = $(this).serialize();
    $.ajax({
        type: 'post',
        url: '/my/user/updatepwd',
        data: rest,
        success: function (res) {
            console.log(res);
            layer.msg(res.message)
            if (res.status === 0) {
                localStorage.removeItem('token');
                window.parent.location.href = '../login.html';

            }

        }
    })
})

